﻿using Itech_Run.Blog.Application.Contracts.Service;
using Itech_Run.HttpApi.Shared.Result;
using Itech_Run.HttpApi.Shared;
using Itech_Run.HttpApi.Shared.Options;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;

namespace Itech_Run.Blog.HttpApi.Controllers
{
    public class BlogPersonLabelController : BaseApiController
    {
        private readonly IBlogPersonLabelService _blogPersonLabelService;
        private readonly IOptions<OtherOptions> _otherOptions;
        public BlogPersonLabelController(IBlogPersonLabelService blogPersonLabelService, IOptions<OtherOptions> otherOptions)
        {
            _blogPersonLabelService = blogPersonLabelService;
            _otherOptions = otherOptions;
        }

        [HttpGet]
        public async Task<CustomResult> GetListAsync()
        {
            string operateUser = GetOperateId();
            return new CustomResult(await _blogPersonLabelService.GetListAsync(operateUser));
        }

        [AllowAnonymous]
        [HttpGet]
        public async Task<CustomResult> GetHotListAsync()
        {
            string operateUser = GetOperateId();
            if (operateUser == "")
            {
                operateUser = _otherOptions.Value.DefaultUserId;
            }
            return new CustomResult(await _blogPersonLabelService.GetHotListAsync(operateUser));
        }
    }
}
